Scheduler - Refactor Appointments Collection - Resizing#34187
Scheduler - Refactor Appointments Collection - Resizing#34187bit-byte0 wants to merge 16 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors Scheduler appointment resizing by moving resize calculations/config into dedicated helpers, wiring the “new appointments” rendering to use dxResizable, and adding Escape-to-cancel support at the internal Resizable level.
Changes:
- Added
onCancelByEsc+onResizeCancelflow to internal Resizable, including ESC key handling and cancel/restore logic. - Implemented new Scheduler appointment resizing pipeline (config generation, delta-time calculation, resized date range calculation) and integrated it into
scheduler.ts. - Enabled resize handles for grid appointments in the “new appointments” implementation and added/updated Jest coverage for the new behavior.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/devextreme/js/__internal/ui/resizable/resizable.ts | Adds ESC cancellation support and a new cancel action for Resizable. |
| packages/devextreme/js/__internal/ui/resizable/resizable.test.ts | New unit tests validating ESC-cancel behavior and event firing. |
| packages/devextreme/js/__internal/scheduler/scheduler.ts | Integrates new resizing logic/config into Scheduler and updates resize start/end handling. |
| packages/devextreme/js/__internal/scheduler/appointments_new/resizing/get_resized_dates.ts | New helper to compute resized start/end dates with working-hours correction + TZ offset adjustments. |
| packages/devextreme/js/__internal/scheduler/appointments_new/resizing/get_resized_dates.test.ts | Tests for start/end resize date calculations and handle-direction logic. |
| packages/devextreme/js/__internal/scheduler/appointments_new/resizing/get_resizable_config.ts | New helper to generate Resizable rules (handles/step/min sizes) based on view model/workspace. |
| packages/devextreme/js/__internal/scheduler/appointments_new/resizing/get_resizable_config.test.ts | Tests for resizable rule generation (vertical/horizontal/reduced/RTL/grouping). |
| packages/devextreme/js/__internal/scheduler/appointments_new/resizing/get_delta_time.ts | New helper to compute resize delta-time from pixel deltas across view types. |
| packages/devextreme/js/__internal/scheduler/appointments_new/resizing/get_delta_time.test.ts | Tests for delta-time calculation across view types and all-day/timeline behavior. |
| packages/devextreme/js/__internal/scheduler/appointments_new/appointments.ts | Adds getResizableConfig hook and passes resize settings into GridAppointmentView. |
| packages/devextreme/js/__internal/scheduler/appointments_new/appointments.test.ts | Updates test properties to include getResizableConfig. |
| packages/devextreme/js/__internal/scheduler/appointments_new/appointments.focus_controller.ts | Exposes focusViewItem to support focusing the resized appointment. |
| packages/devextreme/js/__internal/scheduler/appointments_new/appointment/grid_appointment.ts | Creates a Resizable instance for grid appointments when resizing is enabled. |
| packages/devextreme/js/__internal/scheduler/appointments_new/appointment/grid_appointment.test.ts | Tests that resize handles appear/disappear based on allowResize. |
| packages/devextreme/js/__internal/scheduler/tests/appointments_resizing.test.ts | Integration tests for resize handles rendering and focus-on-resize-start in Scheduler. |
| private onAppointmentResizeEnd(e: AppointmentResizeEvent): void { | ||
| const $element = $(e.element); | ||
| const settings = this._appointments | ||
| .getAppointmentSettings($element) as AppointmentItemViewModel; |
There was a problem hiding this comment.
settings can return undefined here. We should add guard
if (!settings) {
return;
}
to avoid type error in runtime
| return handles.top; | ||
| }; | ||
|
|
||
| const correctEndDateByDelta = ( |
There was a problem hiding this comment.
correctStartDateByDelta/correctEndDateByDelta — are they almost the same here?
| const adapter = new AppointmentAdapter(rawAppointment, this._dataAccessors); | ||
| const { startDateTimeZone, isRecurrent } = adapter; | ||
|
|
||
| if (!e.handles.top && !isRecurrent) { |
There was a problem hiding this comment.
in old _getEndResizeAppointmentStartDate there was a guard check for appointment not being allDay. In new method we don't have it. Is it by a choice?
What
Added appointment resizing (timed + all-day) to the new appointments collection behind the
_newAppointmentsflag with Esc-to-cancel, focus handling, group-bounded drag, and rollback on cancel/failureHow
Extracted the resize math into small pure, unit-tested helpers; added opt-in
onCancelByEscto theResizablewidget; wired it into the new grid appointment with a thinscheduler.tshandler that computes the new dates (timed vs all-day) and updates the appointment, focusing it on resize-start and snapping it back if the update is cancelled/fails